package com.itbbfx.service.register.impl;

import com.itbbfx.entity.*;
import com.itbbfx.mapper.register.CcashierMapper;
import com.itbbfx.service.register.CcashierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CCashierServiceImpl implements CcashierService {

    @Autowired
    private CcashierMapper cashierMapper;


    @Override
    public Integer selyi(Integer reid) {
        return cashierMapper.selyi(reid);
    }

    @Override
    public Integer pay(Integer reid) {
        return cashierMapper.pay(reid);
    }

    @Override
    public int paya(Integer reid) {
        return cashierMapper.paya(reid);
    }

    @Override
    public String hospital(Integer reid) {
        return cashierMapper.hospital(reid);
    }

    @Override
    public List<CWarehuose> selPharmacy() {
        return cashierMapper.selPharmacy();
    }

    @Override
    public List<ReportVo> selAll() {
        return cashierMapper.selAll();
    }

    @Override
    public List<CPharmacy> drugInformation(CPharmacy cPharmacy) {
        return cashierMapper.drugInformation(cPharmacy);
    }

    @Override
    public List<CCashier> selAllPrescription(Integer perid) {
        return cashierMapper.selAllPrescription(perid);
    }

    @Override
    public Integer selPrescription(CCashier cCashier) {
        return cashierMapper.selPrescription(cCashier);
    }

    @Override
    public Integer addchu(CCashier cCashier) {
        return cashierMapper.addchu(cCashier);
    }

    @Override
    public Integer deldrunum(CPharmacy cPharmacy) {
        if(cashierMapper.deldrunum(cPharmacy) > 0){
            return 1;
        }

        // 集合
        List<CPharmacy> cPharmacies = cashierMapper.queryPharmacy(cPharmacy.getPharmacyName());

        // 减去
        for (CPharmacy cPharmacy1 : cPharmacies){
            cPharmacy.setDrugstorenum(cPharmacy1.getDrugstorenum()-cPharmacy.getDrugstorenum());
        }


        // 存回数据库
        return cashierMapper.deldrunum(cPharmacy);
    }

    @Override
    public Integer upchu(CCashier cCashier) {
        return cashierMapper.upchu(cCashier);
    }

    @Override
    public List<ReportVo> fuzzyQuery(ReportVo reportVo) {
        return cashierMapper.fuzzyQuery(reportVo);
    }

    @Override
    public Integer del(CCashier cCashier) {
        return cashierMapper.del(cCashier);
    }

    @Override
    public Integer adddrunum(CPharmacy cPharmacy) {
        return cashierMapper.adddrunum(cPharmacy);
    }

    @Override
    public String inspectionResults(Integer reid) {
        return cashierMapper.inspectionResults(reid);
    }

    @Override
    public String selbing(Integer reid) {
        return cashierMapper.selbing(reid);
    }

    @Override
    public Integer addbing(CReport cReport) {
        return cashierMapper.addbing(cReport);
    }

    @Override
    public List<CCashier> selUserPrescription(Integer perid) {
        return cashierMapper.selUserPrescription(perid);
    }

    @Override
    public List<CCashier> selpepi(Integer perid) {
        return cashierMapper.selpepi(perid);
    }


}
